package com.ruoyi.mespro.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mespro.domain.ShaftJar;
import com.ruoyi.mespro.service.IShaftJarService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 缸号管理Controller
 * 
 * @author JunXiang
 * @date 2022-08-01
 */
@RestController
@RequestMapping("/mesana/jar")
public class ShaftJarController extends BaseController
{
    @Autowired
    private IShaftJarService shaftJarService;

    /**
     * 查询缸号管理列表
     */
    /*@PreAuthorize("@ss.hasPermi('mesana:jar:list')")*/
    @GetMapping("/list")
    public TableDataInfo list(ShaftJar shaftJar)
    {
        startPage();
        List<ShaftJar> list = shaftJarService.selectShaftJarList(shaftJar);
        return getDataTable(list);
    }

    /**
     * 导出缸号管理列表
     */
    /*@PreAuthorize("@ss.hasPermi('mesana:jar:export')")*/
    @Log(title = "缸号管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ShaftJar shaftJar)
    {
        List<ShaftJar> list = shaftJarService.selectShaftJarList(shaftJar);
        ExcelUtil<ShaftJar> util = new ExcelUtil<ShaftJar>(ShaftJar.class);
        return util.exportExcel(list, "缸号管理数据");
    }

    /**
     * 获取缸号管理详细信息
     */
   /* @PreAuthorize("@ss.hasPermi('mesana:jar:query')")*/
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(shaftJarService.selectShaftJarById(id));
    }

    /**
     * 新增缸号管理
     */
   /* @PreAuthorize("@ss.hasPermi('mesana:jar:add')")*/
    @Log(title = "缸号管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShaftJar shaftJar)
    {
        return toAjax(shaftJarService.insertShaftJar(shaftJar));
    }

    /**
     * 修改缸号管理
     */
   /* @PreAuthorize("@ss.hasPermi('mesana:jar:edit')")*/
    @Log(title = "缸号管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShaftJar shaftJar)
    {
        return toAjax(shaftJarService.updateShaftJar(shaftJar));
    }

    /**
     * 删除缸号管理
     */
   /* @PreAuthorize("@ss.hasPermi('mesana:jar:remove')")*/
    @Log(title = "缸号管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(shaftJarService.deleteShaftJarByIds(ids));
    }
}
